import request from './request'

const AI_PREFIX = '/ai'

/**
 * AI智能标签相关接口
 */

// 单个文件AI标签识别
export function recognizeFileTags(fileId: number) {
  return request({
    url: `${AI_PREFIX}/tags/recognize/${fileId}`,
    method: 'post'
  })
}

// 批量AI标签识别
export function batchRecognizeTags(fileIds: number[]) {
  return request({
    url: `${AI_PREFIX}/tags/batch-recognize`,
    method: 'post',
    data: fileIds
  })
}

// 获取推荐标签
export function getRecommendedTags(fileType?: string) {
  return request({
    url: `${AI_PREFIX}/tags/recommended`,
    method: 'get',
    params: { fileType }
  })
}

// 获取热门标签
export function getPopularTags(limit = 20) {
  return request({
    url: `${AI_PREFIX}/tags/popular`,
    method: 'get',
    params: { limit }
  })
}

// 智能分类到相册
export function smartClassifyFiles(fileIds: number[]) {
  return request({
    url: `${AI_PREFIX}/tags/classify`,
    method: 'post',
    data: fileIds
  })
}

// 相似文件检测
export function detectSimilarFiles(fileId: number) {
  return request({
    url: `${AI_PREFIX}/tags/similar/${fileId}`,
    method: 'get'
  })
}

// 内容安全检测
export function contentSafetyCheck(fileId: number) {
  return request({
    url: `${AI_PREFIX}/tags/safety-check/${fileId}`,
    method: 'post'
  })
}

// 获取AI处理统计
export function getAiStatistics() {
  return request({
    url: `${AI_PREFIX}/statistics`,
    method: 'get'
  })
}

// 人脸识别
export function recognizeFaces(fileId: number) {
  return request({
    url: `${AI_PREFIX}/faces/recognize/${fileId}`,
    method: 'post'
  })
}

// 批量人脸识别
export function batchRecognizeFaces(fileIds: number[]) {
  return request({
    url: `${AI_PREFIX}/faces/batch-recognize`,
    method: 'post',
    data: fileIds
  })
}

// 智能描述生成
export function generateDescription(fileId: number) {
  return request({
    url: `${AI_PREFIX}/description/generate/${fileId}`,
    method: 'post'
  })
}

// 批量描述生成
export function batchGenerateDescriptions(fileIds: number[]) {
  return request({
    url: `${AI_PREFIX}/description/batch-generate`,
    method: 'post',
    data: fileIds
  })
}

// 场景识别
export function recognizeScene(fileId: number) {
  return request({
    url: `${AI_PREFIX}/scene/recognize/${fileId}`,
    method: 'post'
  })
}

// 情感分析
export function analyzeSentiment(fileId: number) {
  return request({
    url: `${AI_PREFIX}/sentiment/analyze/${fileId}`,
    method: 'post'
  })
}

// 获取AI处理进度
export function getProcessingProgress(taskId: string) {
  return request({
    url: `${AI_PREFIX}/tasks/${taskId}/progress`,
    method: 'get'
  })
}

// 取消AI任务
export function cancelProcessingTask(taskId: string) {
  return request({
    url: `${AI_PREFIX}/tasks/${taskId}/cancel`,
    method: 'post'
  })
}